using System.Collections;
using System.Collections.Generic;

namespace Examples.StringTemplate
{
    public class PropertyBag : IEnumerable<KeyValuePair<string, object>>
    {
        private static readonly IDictionary<string, object> _bag = new Dictionary<string, object>();

        public PropertyBag()
        {

        }

        public PropertyBag(params Pair[] values)
        {
            new List<Pair>(values).ForEach(pair => this[pair.Key] = pair.Value);
        }


        public object this[string key]
        {
            get { return _bag[key]; }
            set { _bag[key] = value; }
        }

        public IEnumerator<KeyValuePair<string, object>> GetEnumerator()
        {
            return _bag.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }
    }
}